﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfOrderConfirm.aspx.cs" Inherits="msBsc.WebUi.wMall.Seller.wfOrderConfirm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>地接客_订单确认</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/from.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/pagination.css" rel="stylesheet" />

    <link href="/themes/wStyle1/css/orderlist.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/usermenu.css" rel="stylesheet" />

    <link href="/jqPlugin/layer/skin/layer.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Chat/layim.css" rel="stylesheet" />
</head>
<body>
    <div class="wf_all">
        <div id="divLoginInfo">
            <%=msBsc.WebUi.Code.QtHtmlGet.GetHeaderLoginInfo() %>
        </div>
        <div class="main-container">
            <div class="sidebar-scroll noborder">
                <%=msBsc.WebUi.Code.QtHtmlGet.GetDjackMenuHtml() %>
            </div>
            <div class="main-Info">
                <div class="tnavigation">
                    <a class="nav" href="#">首页</a>&gt;
				<a class="nav" href="#">订单管理</a>&gt;
				<a class="nav-on" href="#">我的订单</a>
                    <div class="tinfo right">
                        <span>下单时间：<em id="ordr_time"></em></span>
                        <span>订单号:<em id="order_code"></em></span>
                    </div>
                </div>

                <div id="detailInfo">
                    <p style="width: 200px; margin-left: 30px;" class="car-price">数据加载中请稍后...</p>
                </div>
                <xmp id="svc_list_temp_order" style="display: none">
                      <table class="table-info">
                        <thead class="table-head">
                            <tr>
                                <th class="w2">名称</th>
                                <th class="w2">时间</th>
                                <th>车辆价总价(元)</th>
                            </tr>
                        </thead>
                        <tbody class="user-body">
                            <tr class="tr-one">
                                <td class="w2">
                                    <div class="user-tag">
                                        <div><a href="#">{{d.rows[0].CUSTOMER_NICK}}</a></div>
                                       <span onclick="chatShow(this);" style="cursor:pointer;color:#ff6a00;" lg="true" 
                                        userid="{{d.rows[0].CUSTOMER_REGISTER_ID}}" 
                                        username="{{d.rows[0].CUSTOMER_NICK}}" userface="{{d.rows[0].CUSTOMER_DEFAULT_PIC}}" >
                                            <img src="/themes/wStyle1/Images/Chat/contact.gif" alt="在线咨询" />
                                        </span>
                                    </div>
                                    <img class="user-img" alt="用户头像" src="{{d.rows[0].CUSTOMER_DEFAULT_PIC}}" />
                                </td>
                                <td>{{formatDate1(new Date(d.rows[0].ORDER_START_TIME))}}-{{formatDate1(new Date(d.rows[0].ORDER_STOP_TIME))}}</td>
                                <td>
                                    <p id="price_sum" class="unit-price">￥{{d.rows[0].ORDER_TOTAL_BALANCE}}</p>
                                    <span class="tm-btn tm-skin-yellow">待确认</span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <input type="hidden" id="ordr_time_temp" value="{{formatDate1(new Date(d.rows[0].ORDER_TIME))}}" />
                    <input type="hidden" id="order_code_temp" value="{{d.rows[0].ORDER_CODE}}" />
                        <table class="table-info m-top1">
                        <thead class="table-head">
                            <tr>
                                <th>车辆</th>
                                <th class="w5"></th>
                                <th>单价(元/天)</th>
                            </tr>
                        </thead>
                        <tbody class="car-body">
                           {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                <tr>
                                    <td>
                                        <a href="/wp_VehicleInfo.htm?vehicleId={{d.rows[i].PRODUCT_ID}}" target="_blank">
                                        <img class="car-img" src="{{d.rows[i].IMG_URL}}"></a>

                                    </td>
                                    <td class="car-info">
                                        <p>{{d.rows[i].PRODUCT_NME}}</p>
                                        <%--<p>颜色：<span>红配黑色</span></p>
                                        <p>车牌号：<span>渝V9999</span></p>--%>
                                    </td>
                                    <td class="center-text">
                                        <p class="car-price">￥<span id="price_{{d.rows[i].ORDERS_DETAIL_ID}}">{{d.rows[i].PRODUCT_STRIKE_PRICE}}</span></p>
                                        <p class="center-text">优惠 -￥<span>{{d.rows[i].DETAIL_DISCOUNT}}</span></p>
                                        <p class="center-text hideview">优惠
                                            <input detailid="{{d.rows[i].ORDERS_DETAIL_ID}}" class="up-price" type="text" /></p>
                                    </td>
                                </tr>
                           {{#} }}
                        </tbody>
                    </table>
                    
                   </xmp>
                <div class="zuihou">
                    <div class="zuihou-right" id="Operation">
                    </div>
                    <xmp id="XmpOperation" style="display: none">
                             <div class="zuihou-submit">
                            <span class="up-btn tm-skin-yellow" onclick="upPrice();">修改价格</span>
                            <span class="up-btn tm-skin-red" onclick="submitData()">确认订单</span>
                            <span class="up-btn tm-skin-yellow hideview" onclick="cancelEdit(true);">取消修改</span>
                            <span class="up-btn tm-skin-red hideview" onclick="submitEdit()">确认修改</span>
                        </div>

                        <div class="zuihou-info text-right" >
                            <p><span class="car-price">定金比例:</span><span>{{d.rows[0].DEPOSIT_RATIO*100}}%</span>
                            <select id="selectBili" class="hideview">
                                <option value="0.2">20%</option>
                                <option value="0.5">50%</option>
                            </select>
                            </p>
                            <p>订单总价:<span id="price_sum2" class="car-price">￥{{d.rows[0].ORDER_TOTAL_BALANCE}} (共{{d.rows[0].PRODUCT_QTY}}天)</span>
                                &nbsp;&nbsp;优惠:<span id="price_amt" class="zuihou-price">￥-{{d.rows[0].DISCOUNT_AMT}}</span>
                            </p>
                            
                            <p>
                                应付总价:<span class="car-price">
                                        ￥{{(d.rows[0].ORDER_TOTAL_BALANCE-d.rows[0].DISCOUNT_AMT).toFixed(2)}}</span>&nbsp;&nbsp;
                            应付定金: ￥<span id="din_007" class="zuihou-price">{{d.rows[0].PAYABLE_AMT}}</span>&nbsp;&nbsp;
                            </p>
                        </div>
                     </xmp>
                    <div style="width: 260px; padding-top: 50px; padding-left: 15px;">
                        <p><span class="car-price">注：应付定金=(应付总价-优惠价格) x 付款比例</span></p>
                    </div>
                </div>
            </div>
        </div>
        <%--chat--%>
        <script src="/themes/wStyle1/js/Chat/lib.js"></script>
        <script src="/themes/wStyle1/js/Chat/layim.js"></script>
        <!--start JS引用-->
        <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
        <script src="/jqPlugin/js/jBase.js"></script>
        <script src="/jqPlugin/js/jBPage.js"></script>
        <script src="/jqPlugin/js/laytpl.js"></script>
        <script src="/jqPlugin/layer/layer.min.js"></script>

        <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
        <script src="/themes/wStyle1/js/comm/jsLayout.js"></script>
        <script src="/themes/wStyle1/js/comm/DateInfo.js"></script>
        <script type="text/javascript">
            $(function () {

            })
            //修改价格点击事件
            function upPrice() {
                //隐藏按钮
                var zuihou = $(".zuihou-submit").children();
                $(zuihou).removeClass("hideview");
                $(zuihou).eq(0).addClass("hideview");
                $(zuihou).eq(1).addClass("hideview");

                $(".up-price").parent().prev().addClass("hideview");
                $(".up-price").parent().removeClass("hideview");

                //价格替换
                $(".up-price").each(function (i, e) {
                    $(e).val($(e).parent().prev().children("span").html());
                });

                //比例替换
                $("#selectBili").prev().hide();
                $("#selectBili").show();

                var bl = $("#selectBili").prev().html();
                if (bl == "50%") {
                    $("#selectBili").find("option[value='0.5']").attr("selected", true);
                }
                else {
                    $("#selectBili").find("option[value='0.2']").attr("selected", true);
                }
            }


            //取消编辑 事件
            function cancelEdit(istrue) {
                //隐藏按钮
                var zuihou = $(".zuihou-submit").children();
                $(zuihou).addClass("hideview");
                $(zuihou).eq(0).removeClass("hideview");
                $(zuihou).eq(1).removeClass("hideview");

                $(".up-price").parent().prev().removeClass("hideview");
                $(".up-price").parent().addClass("hideview");
                if (istrue) {
                    $(".up-price").val("");
                }

                //比例替换
                $("#selectBili").prev().show();
                $("#selectBili").hide();
            }
            //提交修改数据
            function submitEdit() {
                //获取减免的价格
                var re = /^(\d+\.\d{1,2}|\d+)$/, isTrue = true, updateDt = "";
                $(".up-price").each(function (i, e) {
                    //判断格式是否正确
                    if (!re.test($(e).val())) {
                        isTrue = false;
                        layer.tips('减免金额只能是数字哦<br/>且只保留两位小数', e, { guide: 1, time: 4 });
                        return false;
                    }
                    var detailid = $(e).attr("detailid");
                    var yprice = $("#price_" + detailid).html();
                    var jprice = $(e).val();
                    if (parseFloat(yprice) < parseFloat(jprice)) {
                        isTrue = false;
                        layer.tips('减免金额不能大于原价<br/>且只保留两位小数', e, { guide: 1, time: 4 });
                        return false;
                    }

                    updateDt += detailid + "," + jprice + "|";

                });
                if (!isTrue) { return; }
                //获取定金比例
                $("#selectBili")
                var bili = $("#selectBili").find("option:selected").val();
                if (bili != "0.2" && bili != "0.5") {
                    layer.tips('比例值超出范围.', e, { guide: 1, time: 4 });
                    return;
                }

                $.layer({
                    shade: [0.5, '#000', true],
                    area: ['auto', 'auto'],
                    dialog: {
                        msg: '你确定这个价格？',
                        btns: 2,
                        type: 4,
                        btn: ['确认', '取消'],
                        yes: function () {
                            layer.load('正在提交,请稍后', 2);
                            //提交服务器
                            var opart = new jsonRow();
                            opart.AddCell("detailList", updateDt);
                            opart.AddCell("orderId", GetQueryStr("orderId"));
                            opart.AddCell("bili", bili);
                            opart.AddCell("ACTION", "updateDetail");
                            ajaxComm(opart);

                        }, no: function () {

                        }
                    }
                });

            }
            //修改 界面数据
            function editData() {
                window.location.reload();
            }

            //确认订单
            function submitData() {
                var din = $("#din_007").html();
                din = parseFloat(din);
                if (din <= 0) {
                    layer.alert('应该付定金应该大于0，请重新修改价格.', 3);
                    return;
                }

                layer.load('提交中,请稍后', 2);
                var opart = new jsonRow();
                opart.AddCell("orderId", GetQueryStr("orderId"));
                opart.AddCell("ACTION", "cOrder");
                ajaxComm(opart);
            }
            //确认跳转
            function succes() {
                layer.alert('操作成功.', 10);
                setTimeout(function () {
                    window.location.href = '/ws_OrderInfo.htm?orderId=' + GetQueryStr("orderId");
                }, 2000);
            }


            function btnDo(sEbtn) {
                var opart = new jsonRow();
                opart.AddCell("orderId", GetQueryStr("orderId"));
                opart.AddCell("ACTION", sEbtn);
                ajaxComm(opart);
            };
            btnDo("init");

            function setOrderCode() {
                $("#order_code").html($("#order_code_temp").val());
                $("#ordr_time").html($("#ordr_time_temp").val());

            }
        </script>
        <script src="/themes/wStyle1/js/Chat/chatMessage.js"></script>
        <%=msBsc.WebUi.Code.QtHtmlGet.GetFloorHtml() %>
    </div>
</body>
</html>
